//
//  StatementView.m
//  WordTutor
//
//  Created by lyh on 15/11/18.
//  Copyright © 2015年 lyh. All rights reserved.
//

#import "StatementView.h"

@interface StatementView ()


@end

@implementation StatementView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.cornerRadius = 10;
        self.clipsToBounds = YES;
        
        // Initialization code
        UILabel *titleLabel=[[UILabel alloc] initWithFrame:CGRectMake(8, 5, frame.size.width, 20)];
        titleLabel.font=[UIFont systemFontOfSize:17.0f];
        titleLabel.textColor=[UIColor whiteColor];
        titleLabel.backgroundColor=[UIColor clearColor];
        titleLabel.text=@"例句";
        [self addSubview:titleLabel];
        
        //Line
        UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(8, 29, frame.size.width-10, 1)];
        lineView.backgroundColor = [UIColor whiteColor];
        [self addSubview:lineView];
        
        //Row Height:67
        UIImageView *imageView=[[UIImageView alloc] initWithFrame:CGRectMake(8, 30, frame.size.width - 10, 178)];
        imageView.image=[UIImage imageNamed:@"Forecast"];
        imageView.backgroundColor=[UIColor clearColor];
        imageView.userInteractionEnabled = YES;
        [self addSubview:imageView];
        self.backgroundColor=[UIColor colorWithWhite:0.0f alpha:0.5f];
        
        self.statementWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width - 10, 178)];
        self.statementWebView.scrollView.bounces = NO;
        
        self.statementWebView.backgroundColor = [UIColor clearColor];
        self.statementWebView.opaque = NO;
        
        [self.statementWebView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextFillColor= 'white'"];
        
        [imageView addSubview:self.statementWebView];
        
        /*
        self.statementLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, frame.size.width - 10, 178)];
        self.statementLabel.userInteractionEnabled = YES;
        self.statementLabel.backgroundColor = [UIColor clearColor];
        self.statementLabel.text = @"self.statementLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, frame.size.width - 10,";
        self.statementLabel.textColor = [UIColor whiteColor];
        self.statementLabel.numberOfLines = 0;
        [imageView addSubview:self.statementLabel];
         */
    }
    return self;
}

-(void)updateStatementView:(NSString *)sentenceString {
    [self.statementWebView loadHTMLString:sentenceString baseURL:nil];
    
}


@end
